package com.vtquang.mymaps;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ViewConfiguration;

import com.google.android.maps.MapView;

public class MyMapView extends MapView {
	private boolean touchStarted = false; 
	private long time = -1;
	private long timedoubletap = ViewConfiguration.getDoubleTapTimeout();

	public MyMapView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) { 
		switch (event.getAction()) {
		case MotionEvent.ACTION_DOWN:
			touchStarted = true; 
			break;
		case MotionEvent.ACTION_MOVE:
			touchStarted = false;
			break;
		case MotionEvent.ACTION_UP:  
			if (touchStarted && (System.currentTimeMillis() - time) < timedoubletap) {
				int x = (int) event.getX();
				int y = (int) event.getY();
				this.getController().zoomInFixing(x, y);
			}
			time = System.currentTimeMillis();
			break;
		}

		return super.onTouchEvent(event);
	}

}
